#include <iostream>
using namespace std;

class Top
{
public:
	Top() {cout << "Top::Top()" << endl;}

	void Func1() {cout << "Top::Func1()" << endl;}
	void topFunc1() {cout << "Top::topFunc1()" << endl;}
public:
	int a;
};

 class Left : public Top
 {
 public:
	 void Func1() {cout << "Left::Func1()" << endl;}
	 void leftFunc1() {cout << "Left::leftFunc1()" << endl;}
 public:
    int b;
 };

 class Right : public Top
 {
 public:
	 void Func1() {cout << "Right::Func1()" << endl;}
	 void rightFunc1() {cout << "Right::rightFunc1()" << endl;}
 public:
    int c;
 };

 //Memory distribution
 //-------
 //Bottom:
 //--------------
 //|Left::Top::a |
 //|-------------|
 //|Left::b      |
 //|-------------|
 //|Right::Top::a|
 //|-------------|
 //|Right::c     |
 //|-------------|
 //|Bottom::d    |
 //|-------------|

 class Bottom : public Left, public Right
 {
 public:
	 void Func1() {cout << "Bottom::Func1()" << endl;}
	 void bottomFunc1() {cout << "Bottom::bottomFunc1()" << endl;}

 public:
    int d;
 };

 void classInheritTest()
 {
	 Bottom bt; //top will construct twice

	 Bottom *bottom = new Bottom();
	 //bottom->topFunc1(); //ambiguous
	 bottom->Left::topFunc1();
	 bottom->Right::topFunc1();

	 Left *left = bottom;
	 left->Func1();
	 left->topFunc1();

	 Right *right = bottom;
	 right->Func1();
	 right->topFunc1();

	// Top *top = bottom; //ambiguous
	 Top *topL = left;
	 topL->Func1();

	 Top *topR = right;
	 topR->Func1();

	 cout << "Size of Button: " << sizeof(Bottom) << endl;
 }
